{% extends 'base.twig' %}
{% block style %}
    <style>
        .table thead tr th{
            height:30px; line-height: 30px; text-align: center;}
        .table tbody tr td{
            height:30px; line-height: 30px; text-align: center;}
    </style>
    <link href="template/plugins/pnotify/css/pnotify.custom.css" rel="stylesheet" type="text/css">
    <script src="template/plugins/pnotify/js/pnotify.custom.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
<section id="main-content">
    <section class="wrapper">
        <div class="row mt">
            <div class="col-lg-12">
                <div class="content-panel">
                    <h4><i class="fa fa-directory"></i> 所有焦点图  <a class="btn btn-success pull-right" href="index_focus.php?act=edit"> 增加焦点图 </a></h4>
                    <section class="filter bg-warning" style="padding: 10px 0;">
                            <form action="index_focus.php" method="GET">
                                <div class="row">
                                    <div class="col-sm-3">
                                        <div class="input-group">
                                            <span class="input-group-addon">域名</span>
                                            <input type="text" class="form-control" name="domain" value="{{ domain }}">
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-default"><i class="fa fa-search"></i> 搜索 </button>
                                </div>
                            </form>
                    </section>
                    <section id="unseen">
                        <table class="table table-bordered ">
                            <thead>
                            <tr>
                                <th>域名</th>
                                <th>排序</th>
                                <th>ID</th>
                                <th>焦点图</th>
                                <th>产品</th>
                                <th>描述</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for g in goodsList %}
                                <tr {% if g.is_del==1 %} class="bg-danger" {% endif %}>
                                    <td>{{g.domain  }}</td>
                                    <td>{{g.sort  }}</td>
                                    <td>{{ g.id }}</td>
                                    <td><img src="{{ g.thumb |replace({"img.stosz.com":"imgcn.stosz.com",'-shop':'-shop80'}) }}" height="50" width="50"> </td>
                                    <td>{{ g.name }}</td>
                                    <td>{{ g.desc }}</td>
                                    <td>
                                        {% if g.is_del ==1 %}
                                            <a class="btn btn-success" onclick="delproduct({{ g.id }},0);"><i class="fa fa-edit"></i> 恢复 </a>
                                        {% else %}
                                            <a class="btn btn-primary" href="index_focus.php?act=edit&id={{ g.id }}"><i class="fa fa-edit"></i> 编辑</a>
                                            <a class="btn btn-danger"  onclick="delproduct({{ g.id }},1);"><i class="fa fa-times"></i> 删除 </a>
                                        {% endif %}
                                        
                                    </td>
                                </tr>
                                
                            {% endfor %}
                            </tbody>
                            
                        </table>
    
                        <div class="text-center">
                            {{ pageHtml|raw }}
                        </div>
                    </section>
                </div>
            </div>
        </div>
    </section>
</section>
    
    <script type="text/javascript">
        highlight_subnav('index_focus.php?');
        function delproduct(mid,is_del) {

            var url = 'index_focus.php?' ;
            var json = {mid:mid,is_del:is_del,act:"delete"};
            if(confirm('确认进行此操作吗？'))
            {
                $.ajax({
                    url : url,
                    data : json,
                    type : "post",
                    dataType:"json",

                    success : function(data) {
                        if(data.ret)
                        {
                            location.reload()
                        }
                        else{
                            new PNotify({
                                title: '错误！！',
                                text: data.msg,
                                type: 'error',
                                addclass: 'stack-bar-top'
                            });
                        }

                    },
                    error:function(XMLHttpRequest, textStatus, errorThrown){
                        alert(errorThrown);
                    }

                });
            }
            
        }
    </script>
{% endblock %}
